#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<errno.h>

int main(int argc, char *argv[]){
    
    
    int fl = fcntl(STDIN_FILENO,F_GETFL,0);
    
    fcntl(STDIN_FILENO,F_SETFL,fl|O_NONBLOCK);
    
    char in[10];
    int r_num;
    while(1){
        
         if((r_num = read(STDIN_FILENO,in,sizeof(in))) < 0){
            
            if(errno != EAGAIN){
                
                break;
            }else{
                 sleep(1);
                printf("请输入:\n");
                fflush(stdout);
            }    
                     
         }else{
             printf("%s\n",in);
         }

    }
      
    return 0;
}

